<%--
 *  File:    DepartmentEdit.jsp
 *  @Author: Kevinfan 
 *  Date:    2011/02/23
 *
 *  Copyright (C) 2000 - 2012 Oval Technologies, Inc.
 *  All rights reserved. 
 *
 *  This software is the confidential and proprietary information of Oval 
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java"%>
<%@ page import="java.util.*"%>
<%@ page import="org.apache.log4j.Category"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom"%>

<%
  //init param
  Category cat = Category.getInstance("jsp.DepartmentEdit");
  String strModuleName = "ERM";
  String privilegeCode = "10386";
  String contextPath = request.getContextPath();
  HashMap userinfo = (HashMap)session.getAttribute("userinfo");
  
%>
<% //--------------------  include files list --%>
<%--@ include file="/inc/Security.inc" --%>
<%@ include file="/inc/PageDefault.inc"%>
<%@ include file="/inc/LocationDefault.inc"%>

<html>
<head>
<title>DepartmentEdit</title>
<PageFlow:CheckPageFlow pageName="p_zylhospdeptedit" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/Calendar.js"></script>
<%
String strDisplayFlag="";
if(request.getParameter("displayflag")!=null)
{
  strDisplayFlag=request.getParameter("displayflag");
}
String isEdit="";
if(request.getParameter("hospitaldeptid")!=null)
{
  isEdit="edit";
}
%>
<script language="JavaScript">
function page_done()
{ 
  if(!checkForm(document.cform))
    return;
  var doctornum=document.cform.doctornum.value;
  var doctornums=document.cform.doctornums.value;
  var status=document.cform.status.value;
  if(Number(doctornum) < Number(doctornums)){
    alert("<%= message.getMessageDesc("Fill_In_The_Numbermust_Be_Greater_Than_The_Actual_Number") %>");
  }
  if(Number(status) == 28){
   if(Number(doctornums) > 0){
     alert("<%= message.getMessageDesc("Departments_And_The_Doctor_Can_NOt_Buy_Associated_Null_And_Void") %>");
     return;
   }
  }
  document.cform.actionname.value = "save";
  document.cform.target = "_self";
  formatDate(cform);
  //isRunning = true;
  __submitData("pageform",true);
}

function page_selectHospital(){
	if(popwindow!=null) popwindow.close();
    url = '<%=contextPath %>/phap/masterdata/erm/HospitalSummaryForPop.jsp?<%= OvalTools.randomURL() %>&languagecode=<%= strLanguageCode %>&countrycode=CN&status=41';
    attribute = 'height=300, width=650,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=no';
	popwindow = window.open(url,'newwindow', attribute);
}
 
function page_selectProduct(){
    var hospitaldeptid=document.cform.hospitaldeptid.value;
	if(popwindow!=null) popwindow.close();
	<%if((strDisplayFlag).equals("view")){%>
	url = '<%=contextPath %>/zyl/masterdata/erm/DepartmentProDate.jsp?<%= OvalTools.randomURL() %>&hospitaldeptid='+hospitaldeptid+'&displayflag=view';
	<%}else{ %>
	url = '<%=contextPath %>/zyl/masterdata/erm/DepartmentProDate.jsp?<%= OvalTools.randomURL() %>&hospitaldeptid='+hospitaldeptid;
	<%} %>
    //url = '<%=contextPath %>/zyl/masterdata/erm/DepartmentProDate.jsp?<%= OvalTools.randomURL() %>&hospitaldeptid='+hospitaldeptid;
    attribute = 'height=300, width=650,top=100,left=100,toolbar=n0, menubar=no, scrollbars=yes, resizable=no, location=no, status=yes';
	popwindow = window.open(url,'newwindow', attribute);
}

function setHospital(id,code,name){
	document.cform.hospitalid.value=id;
	document.cform.hospitalcode.value=code;
	document.cform.hospitalname.value=name;
}

function page_checkNullStr(obj){
	var str=obj.value;
	str = ( str || "" ).replace(/^\s+|\s+$/g, "");
	str = ( str || "" ).replace(/^\　+|\　+$/g, "");
	obj.value=str;
}
function set_repNameByPopWindow(id,code,name){
	//document.cform.employeecode.value=code;
	document.cform.director.value=name;
	document.cform.doctorname.value=name;
	document.cform.directorid.value=id;
}
function page_selectEmp(){
    if(isEmpty(document.cform.hospitalid.value)){
       alert("<%= message.getMessageDesc("Please_First_Choice_Hospital") %>");
       return;
     }
	if(popwindow!=null) popwindow.close();
    url = "<%=contextPath%>/masterdata/upm/ZylDoctorSummary.jsp?<%= OvalTools.randomURL() %>&hospitalid="+document.cform.hospitalid.value+"&category=1";
    attribute = "height=400, width=400,top=120,left=120,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=yes";
	popwindow = window.open(url,"newwindow", attribute);
}
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" cellspacing="0" cellpadding="0">
	<tr>
		<td class="summary_top"></td>
	</tr>
</table>
<table width="100%" cellspacing="0" cellpadding="0">
	<form id="pageform" name="cform" method="post"
		action="<%=contextPath %>/Dispatcher" target="_self"><input
		type="hidden" name="pagename" value="p_zylhospdeptedit"> <custom:hidden
		property="actionname" />
		<custom:hidden name="hospdeptinfo" property="hospitaldeptid" />
	<tr>
		<td valign="top">
		<table border="1" cellspacing="0" bordercolorlight="#999999"
			bordercolordark="#FFFFFF" align="center" width="100%" cellpadding="1">
			<%if(!(strDisplayFlag).equals("view")){%>
			<tr>
				<td colspan="4" class="td_right"><a onclick="page_done()"><custom:button
					type="2" label="L_Save" imgsrc="save_btn.gif" border="0" /></a></td>
			</tr>
			<%}%>
			<tr><%String deptcode = (String)pageContext.getAttribute("deptcode"); %>
				<%if("".equals(deptcode) || deptcode == null){%>
				<td class="need" width="15%"><%= label.getLabelName("L_Detp_Code") + label.getLabelName("L_Colon") %></td>
				<td width="35%"><custom:text property="deptcode" name="hospdeptinfo" label="L_InfoDeptReferenceNo" size="20" /></td>
				<%}else{%>
				<td class="need" width="15%"><%= label.getLabelName("L_Detp_Code") + label.getLabelName("L_Colon") %></td>
				<td width="35%"><custom:text property="deptcode"
					name="hospdeptinfo" label="L_InfoDeptReferenceNo" readonly="true" style="border:0;width:100%" size="20" /></td>
				<%} %>
				<td class="td-text" width="15%"><%= label.getLabelName("L_StandardDept") + label.getLabelName("L_Colon") %></td>
				<td width="35%"><custom:selectdic name="hospdeptinfo" dictType="HospitalDepartment" property="standarddept" 
					label="L_StandardDept"  defaultValue="---------"/></td>
			</tr>
			<tr>
				<td class="need" width="15%"><%= label.getLabelName("L_HospDeptName") + label.getLabelName("L_Colon") %></td>
				<td width="35%"><custom:text name="hospdeptinfo" property="deptname" label="L_HospDeptName" command="notnull" onchange="page_checkNullStr(this)"/></td>
                <td class="need"><%= label.getLabelName("L_BelongHospital") + label.getLabelName("L_Colon") %></td>
				<td><custom:text name="hospdeptinfo" property="hospitalcode"
					command="notnull" label="L_BelongHospital" /> <custom:hidden
					property="hospitalid" name="hospdeptinfo" /><a
					onclick="javascript:page_selectHospital();"><custom:button
					type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a> 
					<custom:text property="hospitalname" name="hospdeptinfo" readonly="readonly" size="20" command="notnull" label="L_BelongHospital" /></td>
			</tr>
			<tr>
				<td class="need"><%= label.getLabelName("L_Responsibility") + label.getLabelName("L_Colon") %></td>
				<td><!--<custom:text property="director" name="hospdeptinfo" label="L_Responsibility" command="notnull" onchange="page_checkNullStr(this)"/>-->
				<custom:text name="hospdeptinfo" property="doctorname"  onchange="page_checkNullStr(this)" readonly="readonly"/>
				<custom:hidden name="hospdeptinfo" property="director" />
           		<a onclick="page_selectEmp();">
                <custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/>
                </a>
                <custom:hidden name="hospdeptinfo" property="directorid" command="notnull" label="L_Responsibility"/>
				</td>
				<td class="td-text"><%= label.getLabelName("L_Filedate") + label.getLabelName("L_Colon") %></td>
				<td>
				
			 <custom:text property="filedate" dataType="date" name="hospdeptinfo" dataFormatName="dateformat" size="20"  label="L_Filedate" onfocus="c.show(this,'cform.filedate','yyyy-MM-dd')" />
					</td>
				
			</tr>
			<tr>
				<td class="td-text"><%= label.getLabelName("L_Updated") + label.getLabelName("L_Colon") %></td>
				<td>
				
			 <custom:text property="updated" dataType="date" name="hospdeptinfo" dataFormatName="dateformat" size="20"  label="L_Updated" onfocus="c.show(this,'cform.updated','yyyy-MM-dd')" />
			
				<td class="need"><%= label.getLabelName("L_Telephone") + label.getLabelName("L_Colon") %></td>
				<td><custom:text property="phone" name="hospdeptinfo" label="L_Telephone" command="notnull"/></td>
				
			</tr>
			<tr>
				<td class="need"><%= label.getLabelName("L_Status") + label.getLabelName("L_Colon") %></td>
				<td><custom:select optionsName="allstatus"
					optionValueKey="statusvalue" optionInnerTextKey="statusname"
					name="hospdeptinfo" label="L_StatusName" property="status"  command="notnull" /></td>
				<td class="need"><%= label.getLabelName("L_DoctorNum") + label.getLabelName("L_Colon") %></td>
				<td><custom:text property="doctornum" name="hospdeptinfo" label="L_DoctorNum" dataType="number"  command="notnull,notnegative"/></td>
				<custom:hidden name="hospdeptinfo" property="doctornums" />
			</tr>
			<tr>
				<td class="need"><%= label.getLabelName("L_SickBed") + label.getLabelName("L_Colon") %></td>
				<td><custom:text property="sickbed" name="hospdeptinfo" label="L_SickBed" dataType="number"  command="notnull,notnegative"/></td>
				<td class="need"><%= label.getLabelName("L_NurseNum") + label.getLabelName("L_Colon") %></td>
				<td><custom:text property="nursenum" name="hospdeptinfo" label="L_NurseNum" dataType="number"  command="notnull,notnegative"/></td>
				
			</tr>
			<tr>
				<td class="need"><%= label.getLabelName("L_Bedturnovernum") + label.getLabelName("L_Colon") %></td>
				<td><custom:text property="bedturnovernum" name="hospdeptinfo" label="L_Bedturnovernum" dataType="number"  command="notnull,notnegative"/></td>
				<td class="need"><%= label.getLabelName("L_DocNurseTotal") + label.getLabelName("L_Colon") %></td>
				<td><custom:text property="docnursetotal" name="hospdeptinfo" label="L_DocNurseTotal" dataType="number"  command="notnull,notnegative"/></td>
				
			</tr>
			<tr>
				<td class="need"><%= label.getLabelName("L_RelatedPatient") + label.getLabelName("L_Colon") %></td>
				<td><custom:text property="relatedpatient" name="hospdeptinfo" label="L_RelatedPatient" dataType="number"  command="notnull,notnegative"/></td>
				<td class="need"><%= label.getLabelName("L_IsImportant") + label.getLabelName("L_Colon") %></td>
				<td>
					<custom:selectdic name="hospdeptinfo" dictType="YesOrNo" property="isimportant" label="L_IsImportant" command="notnull"/>
				</td>
				
			</tr>
			<tr>
				<td class="need"><%= label.getLabelName("L_Advantage") + label.getLabelName("L_Colon") %></td>
				<td><custom:text property="advantage" name="hospdeptinfo" label="L_Advantage" command="notnull"/></td>
				<td class="need"><%= label.getLabelName("L_AcademicPosition") + label.getLabelName("L_Colon") %></td>
				<td><custom:selectdic name="hospdeptinfo" dictType="Position1" property="academicposition1" label="L_AcademicPosition" command="notnull"/>/
					<custom:selectdic name="hospdeptinfo" dictType="Position2" property="academicposition2" label="L_AcademicPosition" command="notnull"/></td>
				
			</tr>
			<tr>
				<td class="td-text"><%= label.getLabelName("L_OfficePhone") + label.getLabelName("L_Colon") %></td>
				<td><custom:text name="hospdeptinfo" property="phone" label="L_OfficePhone"></custom:text></td>
				<td class="need"><%= label.getLabelName("L_Research") + label.getLabelName("L_Colon") %></td>
				<td><custom:text name="hospdeptinfo" property="research" label="L_Research" command="notnull"></custom:text></td>
				
			</tr>
			<tr>
				<td class="need"><%= label.getLabelName("L_Position1") + label.getLabelName("L_Colon") %></td>
				<td><custom:text property="placeposition" name="hospdeptinfo" label="L_Position1" command="notnull"/></td>
				<td class="td-text"><%= label.getLabelName("L_ProdDevelopInfo") + label.getLabelName("L_Colon") %></td>
				<td><!--<custom:text property="proddevelopinfo" name="hospdeptinfo" label="L_ProdDevelopInfo" />-->
				
				<!--<a onclick="javascript:page_selectProduct();"><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0" /></a> -->
				<%if((strDisplayFlag).equals("view")){%>
                 <a  onclick="page_selectProduct()" style="text-decoration: none;font-size: 12px;border:1px #FCAD20 solid;background:#ECE9D8;">*</a>
                <%}else{ %>
                <custom:button type="3" label="L_Asterisk" value="*" border="0" onclick="page_selectProduct()"/>
                 <%} %> 
					
				</td>
				
			</tr>
			<tr>
				<td class="td-text"><%= label.getLabelName("L_DevelopDate") + label.getLabelName("L_Colon") %></td>
				<td>
				
		<custom:text property="developdate" dataType="date" name="hospdeptinfo" dataFormatName="dateformat" size="20"  label="L_DevelopDate" onfocus="c.show(this,'cform.developdate','yyyy-MM-dd')" />
				
				</td>
				<td class="td-text">&nbsp;</td>
				<td>&nbsp;</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td class="summary_top"></td>
	</tr>
	</form>
</table>
</body>
</html>